package com.yuyang.springcloud.service.impl;

import com.yuyang.springcloud.service.MessageProvider;
import com.yuyang.springcloud.service.MessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.support.MessageBuilder;
import javax.annotation.Resource;
import org.springframework.cloud.stream.messaging.Source;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author yu yang
 * @date 2022/11/1 -16:24
 */
@EnableBinding(Source.class) //发送消息的管道与交换机绑定
public class MessageProviderImp implements MessageProvider {
    @Qualifier("output")
    @Autowired
    private MessageChannel messageChannel; // 消息的发送管道
    @Override
    public String send() {
        //发送消息
        messageChannel.send(MessageBuilder.withPayload(UUID.randomUUID().toString()).build());
        return null;

    }
}
